﻿namespace Cubicle.Core.Processors
{
    public abstract class ConditionalQueue<T> : ProcessorQueue<T>
    {
        public abstract bool Condition(T input);

        public override T ProcessQueue(T input)
        {
            T result = input;
            foreach (var t in Queue)
            {
                if (!Condition(result)) return result;
                var processor = t;
                result = processor.Process(result);
            }
            return result;
        }
    }
}